﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tema_cars
{
    class Pool : CarFactory
    {
        static Pool instance;
        public List<Automobil> list;

        public static Pool Instance() //singletone
        {
            if (instance == null)
                instance = new Pool();

            return instance;
        }

        private Pool()
        {
            list = new List<Automobil>();

            list.Add(new TipAutomobil("audi", "sedan", "negru", "auto", "diesel", "3.8m", "sistem audio Bowers & Wilkins, S line"));
            list.Add(new TipAutomobil("mercedes", "sedan", "alb", "auto", "benzina", "3.6m", "parcarea automata,internet, pachet AMG"));
            list.Add(new TipAutomobil("lexus", "sedan", "visiniu", "manuala", "benzina", "4m", "sistem night vision, scaune reglabile electric"));

            list.Add(new TipAutomobil("ford", "mini", "albastru", " auto", "diesel", "1.2m", "incalzire scaune"));
            list.Add(new TipAutomobil("smart", "mini", "verde", " manuala", "benzina", "1.1m", "comanda vocala, sistem de navigatie"));
            list.Add(new TipAutomobil("opel", "mini", "galben", " auto", "diesel", "1.3m", "sistem de navigatie"));

            list.Add(new TipAutomobil("jaguar", "coupe", "negru", "auto", "benzina", "1.8m", "piele crocodil, inlaturare limitator de viteza"));
            list.Add(new TipAutomobil("porsche", "coupe", "rosu", "auto", "benzina", "2m", "airbaguri pentru genunchi, volan si scaune sport"));
            list.Add(new TipAutomobil("bmw", "coupe", "gri", "manuala", "benzina", "2.2m", "volan si scaune sport, jante din aliaj, M Sport"));

        }


        public override Automobil getMasina(string numemasina)
        {
            Automobil masina = new TipAutomobil();
            foreach (Automobil x in list)
                if (x.getName() == numemasina.ToLower())
                    return x;
            return masina;
        }

        public override void delete(Automobil a)
        {
            list.Remove(a);
        }

        public override void print()
        {
            foreach (Automobil a in list)
                a.print();

        }

        public override void adauga()
        {
            string name;
            string type;
            string color;
            string transmission;
            string engine;
            string sizes;
            string accessories;

            Console.Write("-Nume masina: ");
            name = Console.ReadLine();
            Console.Write("\n-Tip masina <sedan/coupe/mini>: ");
            type = Console.ReadLine();
            Console.Write("\n-Culoare masina:");
            color = Console.ReadLine();
            Console.Write("\n-Transmisie masina:");
            transmission = Console.ReadLine();
            Console.Write("\n-Motorizare masina:");
            engine = Console.ReadLine();
            Console.Write("\n-Dimensiuni masina:");
            sizes = Console.ReadLine();
            Console.Write("\n-Dotari masina:");
            accessories = Console.ReadLine();
            list.Add(new TipAutomobil(name, type, color, transmission, engine, sizes, accessories));
        }

    }
}
